package com.itheima.controller.exception;

import com.itheima.businessException.DeleteException;
import com.itheima.businessException.FindException;
import com.itheima.businessException.UpdateException;
import com.itheima.entity.Result;
import com.itheima.businessException.AddException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description：说明
 * @ClassName:ProjectExceptionAdivce
 * @Author:YH
 * @Date:2020/11/25 10:37
 */
@RestController
@ControllerAdvice
public class ProjectExceptionAdivce {
    @ExceptionHandler(AddException.class)
    public Result doAddException(AddException ex){
        return new  Result(false,ex.getMessage());
    }
    @ExceptionHandler(DeleteException.class)
    public Result doDeleteException(DeleteException ex){
        return new  Result(false,ex.getMessage());
    }

    @ExceptionHandler(FindException.class)
    public Result doFindException(FindException ex){
        return new  Result(false,ex.getMessage());
    }

    @ExceptionHandler(UpdateException.class)
    public Result doUpdateException(UpdateException ex){
        return new  Result(false,ex.getMessage());
    }
}
